<template>
	<view class="feedback">
		<titleName :name="name"></titleName>
		<view class="title-bgc"></view>
		<view class="content-wrap">
			<view style="background-color: #fff;padding-top: 24rpx;padding-bottom: 2rpx;margin-bottom: 24rpx;">
				<view class="search-wrap">
					<view class="ipt-wrap">
						<view style="margin-left: 10rpx;flex-shrink: 0;">
							<uni-data-picker style="width: 100%;" placeholder="区域" v-model="queryParams.district"
								class="data-picker" popup-title="请选择所在地区" :localdata="dataTree" @change="sessionChange">
							</uni-data-picker>
						</view>
						<view class="line">

						</view>

						<input type="text" style="width: 150rpx;" v-model="queryParams.content" placeholder="请输入内容"
							placeholder-style="font-weight: 400;font-size: 24rpx;color: #999999;" />
					</view>
					<button @click="getList">查询</button>
				</view>

				<view class="date-wrap">
					<view class="date-ipt" style="width:574rpx;overflow: hidden;position: relative;">
						<template v-if="queryParams.startdate">
							<view class="date">日期</view>
							<view class="line"></view>
						</template>
						<uni-datetime-picker start-placeholder="日" rangeSeparator="—" end-placeholder="期"
							type="daterange" @change="selDate" />
						<uni-icons type="down" v-if="!queryParams.startdate" size="15" style="margin-left: 8rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 74rpx;" />
					</view>
				</view>
			</view>

			<!-- <view class="date-wrap" style="margin-bottom: 10rpx;margin-left: 30rpx;display: flex;align-items: center;">
				<uni-datetime-picker rangeSeparator="—" type="daterange" placeholder="日期" start-placeholder="日"
					end-placeholder="期" @change="selDate" />
				<uni-icons type="down" v-if="!queryParams.startdate" size="15" style="margin-left: 8rpx;" />
			</view> -->
			<view class="statistics-data">
				<view class="data">
					<view class="name">今日</view>
					<view class="val">{{totalData.num_today}}</view>
				</view>
				<view class="line"></view>
				<view class="data">
					<view class="name">本月</view>
					<view class="val">{{totalData.num_month}}</view>
				</view>
				<view class="line"></view>
				<view class="data">
					<view class="name">本年</view>
					<view class="val">{{totalData.num_year}}</view>
				</view>

			</view>
			<view class="total-data">共<text>{{total}}</text>条数据</view>
			<view class="list">
				<noData v-if="dataList.length==0" />
				<view class="item" v-for="item in dataList" :key="item.id" @click="jumpDetail(item)">
					<view class="title-wrap">
						<view class="name">企业名称：{{item.customername}}</view>
						<view class="status"
							:style="item.status==0?'background:#FFC9C9;color:#FA0808':item.status==1?'background:#FEE3CB;color:#FA7408':item.status==2?'background:#CBE2FE;color:#0874FA':''">
							{{item.status==0?'未处理':item.status==1?'处理中':item.status==2?'已处理':''}}
						</view>
					</view>
					<view class="content">
						{{item.content || '无'}}
					</view>
					<view class="bottom">
						<view class="date">{{item.committime}}</view>
						<image
							src="https://splendid.oss-cn-beijing.aliyuncs.com/static/imghazardouswaste/right-arrow.png"
							mode=""></image>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script setup>
	import titleName from '../../components/titleName.vue'
	import noData from '../../components/noDataShow.vue'
	import http from '../../request/index'
	import uploadFile from '../../request/uploadFile.js'
	import {
		onShow,

	} from '@dcloudio/uni-app'
	import {
		nextTick,
		reactive,
		ref
	} from 'vue'
	let dataList = ref([])
	let totalData = ref({})
	let showLine = ref('none')
	let dataTree = ref()
	let total = ref('')

	let queryParams = reactive({

	})
	let name = "反馈管理"
	let adviceTypeList = ref([])
	let sessionChange = (e) => {

		let id = e?.detail?.value[e.detail.value.length - 1]?.value

		queryParams.district = id
	}
	let getList = () => {
		http({
			url: '/feedback/datalist',
			data: {
				...queryParams
			}
		}).then((res) => {
			if (res.code == 0) {
				dataList.value = res.data.list
				total.value = res.data.total
			}


		})
	}

	onShow(() => {
		getList()
	})

	let selDate = (e) => {
		console.log(e, 'e');
		if (e.length == 0) {
			showLine.value = 'none'
			queryParams.startdate = ''
			queryParams.enddate = ''
			return
		}
		queryParams.startdate = e[0]
		queryParams.enddate = e[1]
		showLine.value = 'block'
	}
	let jumpDetail = (msg) => {


		uni.navigateTo({
			url: `/contorllerPageOther/feedbackdetail/feedbackdetail?msg=${JSON.stringify(msg)}`
		})
	}

	function mapTree(data) {
		console.log(data, 'data');
		if (data.length <= 0) return

		return data.map((item) => {
			item.text = item.regionname
			item.value = item.id
			if (item.lstSubNodes && item.lstSubNodes.length > 0) {
				item.children = item.lstSubNodes
				for (var i = 0; i < item.lstSubNodes.length; i++) {

					item.children[i].text = item.lstSubNodes[i].regionname
					item.children[i].value = item.lstSubNodes[i].id
					if (item.lstSubNodes[i].lstSubNodes && item.lstSubNodes[i].lstSubNodes.length > 0) {
						mapTree(item.lstSubNodes[i].lstSubNodes)
					}


				}
			}
			return item

		})

	}
	http({
		url: '/feedback/suminfo'
	}).then((res) => {

		if (res.code == 0) {
			totalData.value = res.data
		}

	})

	http({
		url: '/listitem/getmodule',
		data: {
			module: 'B03'
		}
	}).then((res) => {
		if (res.code == 0) {
			let data = res.data
			adviceTypeList.value = data.map((item) => {
				return {
					text: item.name,
					value: item.id
				}
			})

		}

	})
	http({
		url: '/region/datalisttree'
	}).then((res) => {
		if (res.code == 0) {
			let data = res.data
			let cc = mapTree(data)
			dataTree.value = data



		}

	})
</script>

<style lang="scss" scoped>
	:deep(.uni-select) {
		border: none !important;


		font-weight: 400;
		font-size: 25rpx;
		color: #333333;

	}

	:deep(.icon-calendar) {
		display: none;
	}

	:deep(.range-separator) {
		background-color: #fff;
		display: v-bind('showLine');
		height: 65rpx !important;
		line-height: 63rpx !important;
	}

	:deep(.uniui-down) {
		color: #999 !important;
	}

	:deep(.uniui-clear) {
		font-size: 48rpx !important;
	}

	:deep(.uni-date) {
		background-color: #fff;
		// width: auto !important;
		// flex: none !important;
		overflow: hidden;
	}

	:deep(.uni-date-x) {
		flex: none;
		background-color: none;
		height: 63rpx;
		line-height: 63rpx;
	}


	:deep(.uni-date__x-input) {
		font-weight: 400;
		font-size: 25rpx;
		color: #333333;
		text-align: center;
		background-color: #F3F5F7;
		flex: none;
		background-color: #fff;
	}

	:deep(.input-value-border) {
		border: none !important;
	}


	:deep(.uni-date-editor--x) {
		border: none;
	}

	:deep(.placeholder) {
		font-weight: 400;
		font-size: 25rpx;
		color: #333333;
	}

	.feedback {
		width: 100vw;
		height: 100vh;

		.title-bgc {
			width: 750rpx;
			height: 160rpx;
			background: #0874FA;
		}

		.content-wrap {
			background-color: #F3F5F7;
			width: 100vw;
			height: calc(100vh - 160rpx);
			display: flow-root;
			overflow: hidden;

			.total-data {
				padding-left: 30rpx;
				margin-top: 18rpx;
				margin-bottom: 18rpx;
				font-weight: 400;
				font-size: 23rpx;
				color: #333333;

				text {
					color: #0874FA;
				}
			}

			.list {
				height: calc(100vh - 160rpx - 410rpx);
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-bottom: 56rpx;
				overflow: auto;

				.item:first-child {
					margin-top: 0rpx !important;
				}

				.item {
					width: 707rpx;
					margin-top: 30rpx;
					background: #FFFFFF;
					border-radius: 14rpx;
					padding-left: 40rpx;
					padding-top: 30rpx;
					padding-bottom: 35rpx;

					.title-wrap {
						display: flex;
						align-items: center;

						.name {

							font-weight: 500;
							font-size: 31rpx;
							color: #222222;

						}

						.status {
							margin-left: 38rpx;
							font-weight: 400;
							font-size: 18rpx;
							color: #0874FA;
							width: 84rpx;
							height: 37rpx;
							background: rgba(0, 0, 0, .5);
							border-radius: 10rpx;

							text-align: center;
							line-height: 37rpx;
						}
					}

					.content {
						padding-right: 54rpx;
						font-weight: 400;
						margin-top: 25rpx;
						margin-bottom: 30rpx;
						font-size: 28rpx;
						color: #666666;

					}

					.bottom {
						display: flex;
						padding-right: 30rpx;
						align-items: center;
						justify-content: space-between;

						.data {

							font-weight: 400;
							font-size: 28rpx;
							color: #999999;

						}

						image {
							width: 15rpx;
							height: 25rpx;
						}
					}
				}
			}

			.statistics-data {
				display: flex;
				width: 697rpx;
				height: 149rpx;
				background: #FFFFFF;
				border-radius: 21rpx;
				margin: 0 auto;
				align-items: center;
				padding: 0 90rpx;
				justify-content: space-between;

				.line {
					width: 2rpx;
					height: 26rpx;
					background: #E7E7E7;
				}

				.data {
					display: flex;
					flex-direction: column;

					.name {

						font-weight: 400;
						font-size: 23rpx;
						color: #999999;

					}

					.val {

						font-weight: 400;
						font-size: 35rpx;
						color: #333333;
						text-align: center;
						margin-top: 2rpx;
					}
				}
			}

			.date-wrap {
				padding-left: 22rpx;
				margin-bottom: 20rpx;
				margin-top: 14rpx;

				.date-ipt {
					display: flex;
					max-width: 574rpx;
					align-items: center;
					border: 1px solid #ccc;
					border-radius: 34rpx;
					padding-left: 30rpx !important;

					.date {
						color: #333;
						font-size: 24rpx;
					}

					.line {
						width: 1rpx;
						height: 30rpx;
						background-color: #9eaaba;
						margin-left: 15rpx;
						margin-right: 15rpx;
					}
				}
			}

			.search-wrap {
				display: flex;
				align-items: center;
				// margin-top: 24rpx;
				// margin-bottom: 12rpx;
				padding: 0 22rpx;
				justify-content: space-between;

				.ipt-wrap {
					width: 574rpx;
					height: 67rpx;
					background: #FFFFFF;
					border-radius: 34rpx;
					display: flex;
					align-items: center;
					border: 1px solid #ccc;

					input {
						width: 100%;
						flex-shrink: 1;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
						padding-left: 10rpx;
						padding-right: 10rpx;
					}

					.line {
						width: 1rpx;
						height: 35rpx;
						background: #E8E8E8;
						margin-left: 10rpx;
						margin-right: 10rpx;
					}
				}

				button {
					width: 118rpx;
					height: 67rpx;
					background: #0874FA;
					border-radius: 34rpx;
					font-weight: 400;
					font-size: 25rpx;
					color: #FFFFFF;
					line-height: 67rpx;

				}
			}
		}
	}
</style>